<template>
  <div>
    <!-- 导航 -->
    <van-nav-bar fixed >
      <template #left>
        <van-icon @click="onBack" name="arrow-left" size="20px" color="gray" style="font-weight: bold;width: 20px"/>
      </template>
      <template #title>
        <span style="color: #FF8800;font-size: 18px">收藏夹</span>
      </template>
    </van-nav-bar>
    <div style="padding-top: 50px">
        <!-- 收藏列表 -->
        <ArticleList :articleList="articleList"></ArticleList>
    </div>
  </div>
</template>

<script>
import ArticleList from '@/views/article/ArticleList.vue'
export default {
  name: 'Favorite',
  components: {
    ArticleList
  },
  data () {
    return {
      userId: 0,
      articleList: []
    }
  },
  methods: {
    // 返回
    onBack () {
      this.userId = 0
      this.articleList = []
      this.$router.back()
    },
    // Onload
    onLoad () {
      console.log('this.$route.query.id', parseInt(this.$route.query.id))
      this.userId = parseInt(this.$route.query.id)
      this.$api.getFavoriteArticleListReq({ type: 0, userId: parseInt(this.$route.query.id) }).then(
        resp => {
          this.articleList = resp.articleList
        }
      )
    }
  },
  mounted () {
    // this.onLoad()
  },
  // 页面激活
  activated () {
    if (this.userId <= 0) {
      this.onLoad()
    }
    // console.log('-----activated', this.article.id, this.$route.query.id)
  }
  // activated () {
  //   this.onload()
  // }
}
</script>

<style scoped>

</style>
